//-----------------------------------------------------------------------
// <copyright file="sleep.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
// </copyright>
// <author>James Hartill [Updated: 22-2-08 Mike Fourie. Code Cleanup]</author>
// <email></email>
// <date>2004-03-23</date>
// <summary>Causes the current Thread to sleep for the specfied time.</summary>
//-----------------------------------------------------------------------
namespace Microsoft.Sdc.Tasks
{
    using System.Threading;
    using Microsoft.Build.Framework;

    /// <summary>
    /// Causes the current Thread to sleep for the specfied time.
    /// </summary>
    /// <remarks>
    /// <code><![CDATA[<sleep SleepTimeOut="milliseconds" />]]></code>
    /// <para>where:</para>
    /// <para><i>sleepTimeOut (Required)</i></para>
    /// <para>Number of millseconds to sleep for</para>
    /// </remarks>
    /// <example>
    /// <code><![CDATA[
    /// <Project>
    ///     <Target Name="Test" >
    ///         <sleep sleepTimeOut="30" />
    ///     </Target>
    /// </Project>
    /// ]]></code>    
    /// </example>    
    public class Sleep : TaskBase
    {
        private int sleepTimeout = 0;

        /// <summary>
        /// Specifies the Timeout in milliseconds
        /// </summary>
        /// <value>Number of milliseonds to sleep for</value>
        [Required]
        public int SleepTimeout
        {
            get
            {
                return this.sleepTimeout;
            }

            set
            {
                this.sleepTimeout = value;
            }
        }

        /// <summary>
        /// Performs the action of this task.
        /// </summary>
        protected override void InternalExecute()
        {
            Log.LogMessageFromResources("Sleep", this.sleepTimeout);
            Thread.Sleep(this.sleepTimeout);
        }
    }
}
